import { game } from "../../../../script/game/control/game";
import { ListViewAdapter } from "../../../../script/util/ListView/ListViewAdapter";
import { ccs } from "../../../../script/util/services";
import { WinBase } from "../../../../script/wins/WinBase";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends WinBase {

    // @property(ListViewAdapter)
    // houseList: ListViewAdapter = null;
    
    @property(cc.Node)
    nextBtn: cc.Node = null;
    
    start () {
        //  获取家中的信息，包括房间和娱乐项目
        ccs.gf.extendNodeName(this.nodes, this.node.parent);
        this.touchEndEventScale(this.nextBtn, () => {
            if(game.playerMgr.heroInfo.lifeTime <= 0) {
                return ;
            }
            game.timerMgr.addTime(1);
            game.recordMgr.addList({action: "时光飞逝，一个月过去了", effect: "上月支出" + game.playerMgr.getPayMonth() + "，上月收入： " + game.playerMgr.getIncomeMonth()});
            //生病计算
            game.playerMgr.getDisease();
            game.playerMgr.calPayMonth(); 
            game.playerMgr.reduceTime(-1);
            game.playerMgr.groupUp(); //成长
            game.playerMgr.resetPower(); //重置体力
            game.playerMgr.updateAssets(); //更新资产
            game.playerMgr.updateCompany(); //更新公司
            
            ccs.mainEmitter.emit('updateAttribute');
            ccs.mainEmitter.emit('updateInfo');
            ccs.mainEmitter.emit('refreshCard');
            game.gameMgr.saveGame();
        })
        this.touchEndEventScale(this.nodes.hero, () => {
            ccs.winMgr.showWin("popHeroInfoWin", {info: game.playerMgr.heroInfo});
        })
        this.touchEndEventScale(this.nodes.relation, () => {
            //弹出属性面板
            ccs.winMgr.showWin("popFamilyWin");
        })
        this.touchEndEventScale(this.nodes.money, () => {
            //弹出属性面板
            ccs.winMgr.showWin("popShopWin", {diffcult: 3});
        })
        this.touchEndEventScale(this.nodes.rankBattle, () => {
            ccs.winMgr.showWin('matchWin');
        })
    }
    
    
}
